import request from '@/utils/request';
import { parseStrEmpty } from '@/utils/ruoyi';

// 查询用户列表
export function userList(query: any) {
    return request({
        url: '/api/v1/admin/permission/user/list',
        method: 'get',
        params: query,
    });
}

// 新增用户
export function userAdd(data: any) {
    return request({
        url: '/api/v1/admin/permission/user/add',
        method: 'post',
        data: data,
    });
}

// 修改用户
export function userEdit(data:any) {
  return request({
    url: '/api/v1/admin/permission/user/edit',
    method: 'post',
    data: data
  })
}

// 删除用户
export function userRemove(id:any) {
  return request({
    url: '/api/v1/admin/permission/user/remove',
    method: 'delete',
    data: id
  })
}

// 用户状态修改
export function changeUserStatus(userId:number, status:number) {
    const data = {
        userId,
        status,
    };
    return request({
        url: '/api/v1/admin/permission/user/changeStatus',
        method: 'put',
        data: data,
    });
}

// 用户密码修改
export function userEditPwd(data:any) {
    return request({
        url: '/api/v1/admin/permission/user/update-pwd',
        method: 'post',
        data,
    });
}

// 用户头像上传
export function uploadAvatar(data:any) {
    return request({
        url: '/api/v1/admin/file/user/uploadPic',
        method: 'post',
        data: data,
    });
}